/* $Id: HibernateListener.java 94 2010-10-30 19:03:04Z altdotua@gmail.com $ */

package alt.djudge.frontend.server;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class HibernateListener implements ServletContextListener
{

	public void contextInitialized(ServletContextEvent event)
	{
		if (!Deployment.isGAE())
		{
			// Just call the static
			// initializer of that class
			HibernateUtil.getSessionFactory(); 
		}
	}

	public void contextDestroyed(ServletContextEvent event)
	{
		if (!Deployment.isGAE())
		{
			// Free all resources
			HibernateUtil.getSessionFactory().close();
		}
	}
}
